$(function(){
	//商品购买
	$('a[rel]').click(function(){
		var product_id = $(this).attr('rel');
		$.post('cart.php?act=add&pid='+product_id,{r:Math.random()},function(data){
			if (data.state != 1)
			{
				alert(data.message);
				if (data.state == -403)
				{
					window.location.href = 'user.php?act=login';
				}
			}
			else
			{
				if (confirm('添加到购物车成功，是否立即查看？'))
				{
					window.location.href = 'cart.php?v=1';
				}
			}			
		},'json');
		return false;
	});
});